<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ page import="com.gouwudai.gobbs.pojo.TbbsClass,com.gouwudai.gobbs.pojo.TbbsBlackList,com.gouwudai.gobbs.pojo.TbbsUserInfo"%>
<%@ include file="../common/common.jsp" %>
<%@ include file="user_pass2.jsp" %>
<%
int classId = ParamUtils.getIntParameter(request, "classId", 0);

IClassService classService = (IClassService)BeanManager.getBean("classService");
TbbsClass currentClass = null;
/***************** 权限管理模块 START *********************/
//判断当前版面是否存在
try
{
	currentClass = classService.load(new Integer(classId));
}
catch(Exception e)
{
	HtmlConst.errors(out,7,"您浏览的版面不存在或已被删除！");
	return;
}
//判断用户类型 START
IClassUserService classUserService = (IClassUserService)BeanManager.getBean("classUserService");
int operatorType = 0;//当前用户的类型，-1：游客，0：普通，1:发帖人，2：版主
if(classUserService.isClassManager(new Integer(classId),USER_ID))	//验证用户是否为版主
{
	operatorType = 2;
}
//判断用户类型 END
if(operatorType<2)
{
	HtmlConst.errors(out,1,"您不是该版的版主，没有当前操作的权限！");
	return;
}
	
userLogin.hasClassPermission(new Integer(classId),4009);//公告管理权限	
/***************** 权限管理模块 END *********************/
String className = currentClass.getClassName();
//目前支持3级栏目
Integer parentId = currentClass.getParentId();//父栏目ID，如果不为空则说明有父栏目
String parentName = "";
TbbsClass parentClass = null;
Integer grandId = null;//二级父栏目ID，如果不为空则说明有父栏目
String grandName = "";
TbbsClass grandIdClass = null;
if(parentId!=null&&parentId.intValue()>0)
{
	parentClass = classService.load(parentId);	
	parentName = parentClass.getClassName();
	grandId = parentClass.getParentId();
}
if(grandId!=null&&grandId.intValue()>0)
{
	grandIdClass = classService.load(grandId);	
	grandName = grandIdClass.getClassName();
}

StringBuilder totalClassName = new StringBuilder(50);//栏目全名，包括父栏目
if(grandId!=null&&grandId.intValue()>0)
{
	totalClassName.append(grandIdClass.getClassName());
	totalClassName.append(" - ");
}
if(parentId!=null&&parentId.intValue()>0)
{
	totalClassName.append(parentClass.getClassName());
	totalClassName.append(" - ");
}
totalClassName.append(currentClass.getClassName());
/***************************************************/
Integer blackId = ParamUtils.getIntParameter(request, "blackId");

IBlackListService blackListService = (IBlackListService)BeanManager.getBean("blackListService");
TbbsBlackList tbbsBlackList = blackListService.load(blackId);

IUserService  userService = (IUserService)BeanManager.getBean("userService");
TbbsUserInfo tbbsUserInfo = userService.load(tbbsBlackList.getUserId());
%>
<HTML>
<HEAD>
<title>编辑黑名单</title>
<%@ include file="../common/meta.inc" %>
<link href="css/defaultStyle.css" rel="stylesheet" type="text/css">
<script language="javascript" src="${pageContext.request.contextPath}/scripts/common-validator.js"></script>
<script language="javascript" type="text/javascript" src="scripts/showMenu.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/prototype.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/buffalo/buffalo.js"></script>
<script language="javascript">
var END_POINT="${pageContext.request.contextPath}/buffalo";
var buffalo = new Buffalo(END_POINT);
function doSubmit() {

	form = document.theform;
	
	if(!validateForm(form))
		return;
	
	var obj = {};
	obj[Buffalo.BOCLASS] = "java.util.HashMap";
	obj.blackId=<%=blackId%>;
	obj.blackType=parseInt($F('blackType'));
	obj.limitTime=parseInt($F('limitTime'));
	obj.reason=$F('reason');
    
    buffalo.remoteCall("blackListServiceAjaxService.update",[obj], function(reply) {
        ajaxSubmit(reply.getResult(),"保存成功！","back");
    });
}

function validateForm(form)
{    
    if(!sl_checkChoice(form.blackType,"限制内容")) return false;
    if(!sl_checkIntValue(form.limitTime,"限制时间",9999,0)) return false;
    if(!sl_checkNull(form.reason,"限制理由")) return false;
    return sl_confirmUpdate();
}

</script>
</HEAD>
<BODY>
<%@ include file="../common/waiting.inc" %>
<SCRIPT language="javascript">
setStatus('<%=SYSTITLE%> - <%=totalClassName.toString() %> - 编辑黑名单');
</SCRIPT>
<script language="javascript" type="text/javascript" src="template/scripts/topBar.js"></script>
<DIV class="line"></DIV>
<DIV class="list_table_0">
	<%=HtmlConst.navMenu(HtmlConst.navClassMenu(new Integer(classId),parentId,grandId,className,parentName,grandName ))%>&gt;&gt;编辑黑名单
</DIV>
<DIV class="line"></DIV>
<jsp:include flush="true" page="includes/class_manage_menu.jsp?classId=<%=classId %>"></jsp:include>
<form name="theform" method="post" action="">
<table class="bluetable" width="100%" cellpadding="1" cellspacing="1">	
	<tr>
	    <th colspan="2">编辑黑名单</th>
	</tr>							
	<tr>
		<td class="title" align="right">用户名称:</td>
		<td><%=tbbsUserInfo.getLoginId() %> - <%=tbbsUserInfo.getUserName() %></td>
	</tr>	
	<tr>
		<td class="title" align="right">限制内容:</td>
		<td><select name="blackType" id="blackType">
				<%=Arguments.getDictParamOptions("BL01",tbbsBlackList.getBlackType()) %>
			</select></td>
	</tr>	
	<tr>
		<td class="title" align="right">限制时间:</td>
		<td><input type="text" name="limitTime" id="limitTime" value="<%=tbbsBlackList.getLimitTime() %>" onkeydown="javascript:nextKeyPress(this)" size="4" maxlength="4">分钟<span class="remark">（0为永久黑名单）</span></td>
	</tr>
	<tr>
		<td class="title" align="right" valign="top">限制理由:</td>
		<td><textarea name="reason" id="reason" cols="50" rows="8"><%=tbbsBlackList.getReason() %></textarea></td>
	</tr>																																				
</table>
<table border="0" width="100%">
	<tr>
		<td align="right">
		<button class="btn" accessKey=s id="btnSave" name="btnSave" onclick="javascript:doSubmit();">保存(<u>S</u>)</button>
		&nbsp;&nbsp;
		<button class="btn" accessKey=c id="btnCancel" name="btnCancel" onclick="javascript:history.back();">取消(<u>C</u>)</button>
		&nbsp;&nbsp;								
		</td>
	</tr>
</table>
</form>
<%=COPYRIGHTFOOT%>
<%@ include file="../common/foot.inc"%>	
</BODY>
</HTML>

